package com.esm.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.esm.service.AddRecordService_zxk;
import com.esm.serviceimpl.AddRecordServiceImpl_zxk;

import net.sf.json.JSONObject;
/**
 * 添加请假记录 Controller
 * @author 康少
 *
 * 2017年1月4日
 */
public class AddLeaveController_zxk extends HttpServlet{
	AddRecordService_zxk record = new AddRecordServiceImpl_zxk();
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		int uid = Integer.parseInt(req.getParameter("uid"));
		String uname = req.getParameter("uname");
		String state = req.getParameter("state");
		String time = req.getParameter("time");
		String date = req.getParameter("date");
		String remark = req.getParameter("remark");
		boolean flag = record.AddLeave(uid, uname, state, time, date, remark);
		JSONObject j = new JSONObject();
		j.put("flag", flag);
		PrintWriter pw = resp.getWriter();
		pw.write(j.toString());
		pw.flush();
		pw.close();
	}
}
